<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>树莓派热点管理</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <style>
    body {
      background-color: #f4f7fc;
      font-family: 'Arial', sans-serif;
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0;
      padding: 20px;
    }

    .card {
      width: 100%;
      max-width: 600px;
      padding: 40px 30px;
      border-radius: 15px;
      background-color: #fff;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    }

    h2 {
      font-size: 26px;
      margin-bottom: 30px;
      color: #333;
      text-align: center;
      font-weight: bold;
    }

    .form-label {
      font-size: 16px;
      color: #333;
      margin-top: 15px;
    }

    .form-control {
      border-radius: 8px;
      font-size: 16px;
      padding: 12px;
      margin-bottom: 25px;
    }

    .btn {
      width: 100%;
      padding: 14px;
      font-size: 16px;
      border-radius: 10px;
      text-transform: uppercase;
      text-align: center;
      display: block;
    }

    .btn + .btn {
      margin-top: 20px; /* 更大的间距 */
    }

    .btn-primary {
      background-color: #007bff;
      border: none;
      color: #fff;
    }

    .btn-primary:hover {
      background-color: #0056b3;
    }

    .btn-secondary {
      background-color: #6c757d;
      border: none;
      color: #fff; /* 白字 */
    }

    .btn-secondary:hover {
      background-color: #5a6268;
    }

    .alert {
      border-radius: 8px;
      font-size: 14px;
      margin-bottom: 20px;
    }
  </style>
</head>
<body>

<div class="card">
  <h2>热点信息管理界面</h2>

  {% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
      {% for category, message in messages %}
        <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
          {{ message }}
          <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="关闭"></button>
        </div>
      {% endfor %}
    {% endif %}
  {% endwith %}

  <form method="POST" action="http://192.168.137.2:8080/update">
    <label class="form-label">热点名称（SSID）</label>
    <input type="text" name="ssid" class="form-control" value="{{ config['ssid'] }}" required>

    <label class="form-label">密码</label>
    <input type="text" name="password" class="form-control" value="{{ config['wpa_passphrase'] }}" required>

    <label class="form-label">频道（Channel）</label>
    <input type="number" name="channel" class="form-control" value="{{ config['channel'] }}" required>

    <button type="submit" class="btn btn-primary mb-4">保存并重启热点</button>
  </form>

  <a href="http://192.168.137.2:8080/devices" class="btn btn-secondary">查看连接设备</a>
  <a href="http://192.168.137.2:8080/info" class="btn btn-secondary">查看热点信息</a>
  <a href="http://192.168.137.2:8080/llm" class="btn btn-secondary">大模型对话</a>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
